var registStore=new Ext.data.Store({
	proxy : new Ext.data.HttpProxy({
		url : 'showRegistApplicationList',
		method : 'post'
	}),
	reader : new Ext.data.JsonReader({
		root : 'registApplicationList',
		totalProperty : 'totalRegistApplicationList',
		id : 'id'
	}, [{
		name : 'id'
	}, {
		name : 'name'
	}, {
		name : 'company'
	}, {
		name : 'password'
	}]),
	remoteSort: false
});

//表格列模型
var registsm=new Ext.grid.CheckboxSelectionModel ({singleSelect : true});
var registColumnModel=new Ext.grid.ColumnModel([privilegesm,
	new Ext.grid.RowNumberer(),
	{
		header : '注册申请编号',
		width : 100,
		dataIndex : 'id',
		sortable : true,
		id : 'id'
	}, {
		header : '用户名',
		width : 120,
		dataIndex : 'name',
		sortable : true,
		align : 'center'
	}, {
		header : '公司名',
		width : 60,
		dataIndex : 'company',
		sortable : true,
		align : 'right'
	}, {
		header : '操作',
		width : 120,
		dataIndex : 'status',
		sortable : false,
		renderer : function(value, cellmeta, record, rowIndex, columnIndex,store) {		
			var v=record.get('status');
			var recid=record.get('id');
			var btn="";
			btn='<div id="ra_div_'+recid+'"><button type="button" onclick="approveRegist('+recid+')">批准</button>'
			+' <button type="button" onclick="rejectRegist('+recid+')">驳回</button></div>';			
			return btn;
		}
	}]
);

var registList=new Ext.grid.EditorGridPanel({
	id:'registlist-panel',
	title:'审批注册申请',
	showPage:function(){
		registStore.load();
	},
	enableColumnResize : true,
	border : true,
	clicksToEdit:1,
	enableColumnMove : true,
	enableHdMenu : false,
	stripeRows: true, //显示斑马线
	loadMask: true,
	autoHeight:true,
	bodyStyle:'width:100%',
    autoWidth:true,
    editable:true,
    sm : registsm,
	bbar: new Ext.PagingToolbar({//下面的分页条
        pageSize: 15,
        store: registStore,
        displayInfo: true,
        displayMsg: '当前显示第 {0} 条到 {1} 条记录，一共 {2} 条',
        emptyMsg: "没有记录",
        lastText:"尾页",   
        nextText :"下一页",   
        prevText :"上一页",   
        firstText :"首页",   
        refreshText:"刷新页面"        
    }),
//    tbar:[{
//		xtype:'button',
//		iconCls : 'db-icn-upload_',
//		width:100,
//		text:'提交修改',
//		handler:submitModifiedPrivilege
//	},
//		{xtype : "tbseparator"}
//	],
	cm : registColumnModel,
	store : registStore
	
});

function approveRegist(recid){
	Ext.Ajax.request({
		url: 'approveRegist.action?method=approveRegist&id='+recid,				   	
	   	success: function(res,opt){	
	   		registStore.load();
	   		Ext.Msg.alert('消息','操作成功！');
	   		
	   	},
	   	failure: function(){
	   		
	   	}
	});
}

function rejectRegist(recid){
	Ext.Ajax.request({
		url: 'rejectRegist.action?method=rejectRegist&id='+recid,				   	
	   	success: function(res,opt){	
	   		registStore.load();
	   		Ext.Msg.alert('消息','操作成功！');	   		
	   	},
	   	failure: function(){
	   		
	   	}
	});
}